/**
 * JAVACC DEMO 1.0
 */
package com.apache.portal.contorller.trans;

import com.apache.api.vo.ResultEntity;
import com.apache.api.vo.ResultMsg;
import com.apache.api.vo.Token;
import com.apache.cache.util.Validator;
import com.apache.client.DictCoreClient;
import com.apache.dict.entity.DataCate;
import com.apache.excp.RuturnConfig;
import com.apache.excp.RuturnPropertyParam;
import com.apache.excp.core.impl.LoadManager;
import com.apache.excp.core.impl.imp.ImplExeclPluginsImpl;
import com.apache.excp.core.manager.ImportExecl;
import com.apache.excp.core.model.ExportVo;
import com.apache.excp.core.model.ImportVo;
import com.apache.portal.common.PortalPlugin;
import com.apache.portal.common.annotion.BeanFactory;
import com.apache.portal.common.connector.impl.AdapterFactory;
import com.apache.portal.common.oscache.CacheHelper;
import com.apache.portal.common.restfull.RequestMapping;
import com.apache.portal.common.restfull.ResultFullAnntation;
import com.apache.portal.common.restfull.SupperAction;
import com.apache.portal.common.util.FileOperate;
import com.apache.portal.common.util.PortalPubFactory;
import com.apache.portal.task.ScheduledExecutor;
import com.apache.portal.thread.*;
import com.apache.tools.*;
import com.apache.uct.common.LoginUser;
import com.apache.uct.common.ToolsUtil;
import com.apache.websocket.WebsocketClient;
import com.apache.workday.Workday;
import com.apache.workday.WorkdayUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Method;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.concurrent.Future;

/**
 * description:  对象信息增删改操作公共接口实现Action
 *
 * @author dyhou 创建时间：2016-7-7
 */
@SuppressWarnings("serial")
@ResultFullAnntation(name = "transSubmitAction", urlPatterns = "/trans/submit/*")
public class TransSubmitAction extends SupperAction {

    private PortalPlugin netPlugin;

    private PortalPlugin fusPlugin;

    private PortalPlugin orgPlugin;

    private PortalPlugin uctPlugin;

    private PortalPlugin memberPlugin;

    private PortalPlugin auditPlugin;

    private PortalPlugin dictPlugin;

    private PortalPlugin wcmPlugin;


    public void init() {
        netPlugin = (PortalPlugin) BeanFactory.getInstance().getBeans("net");
        fusPlugin = (PortalPlugin) BeanFactory.getInstance().getBeans("fus");
        orgPlugin = (PortalPlugin) BeanFactory.getInstance().getBeans("org");
        uctPlugin = (PortalPlugin) BeanFactory.getInstance().getBeans("uct");
        memberPlugin = (PortalPlugin) BeanFactory.getInstance().getBeans("member");
        auditPlugin = (PortalPlugin) BeanFactory.getInstance().getBeans("audit");
        dictPlugin = (PortalPlugin) BeanFactory.getInstance().getBeans("dict");
        wcmPlugin = (PortalPlugin) BeanFactory.getInstance().getBeans("wcm");
    }

    private Logger log = LoggerFactory.getLogger(getClass());

    /**
     */
    public void doInvoke(HttpServletRequest request, HttpServletResponse response,
            String methodType) throws Exception {
        String doCode = request.getParameter("doCode");
        LoginUser loginUser = PortalPubFactory.getInstance().getLoginUser(request);
        if (ToolsUtil.isEmpty(loginUser)) {
            gotoLogin(request, response, "");
            return;
        }
        doCode = StrUtil.doNull(doCode, "dymicSql");
        Method method = doInvoke(this.getClass(), request, response, methodType, doCode);
        if (null != method) {
            //			System.out.println(request.getParameter("formToken"));
            boolean flag = checkToken(request, method);
            if (!flag) {
                log.info("token验证结果=" + flag);
                return;
            }
            Object obj = method.invoke(this, request, response, loginUser);
            String auditCode = request.getParameter("auditCode");

            //此拦截仅仅为了审核audit表，必传参数为auditId，auditCode，auditsStatus
            if (!"auditSave".equals(doCode) && Validator.isNotNull(auditCode) && "auditSave"
                    .equals(auditCode)) {
                if (StrUtil.isNotNull(request.getParameter("auditsId"))) {
                    Method auditMethod = doInvoke(this.getClass(), request, response, methodType,
                            auditCode);
                    Object auditObj = auditMethod.invoke(this, request, response, loginUser);
                }
            }

            if (!ToolsUtil.isEmpty(obj)) {
                //判断是否执行流程相关的
                String flowCode = request.getParameter("flowCode");
                String resultFlag = "F";
                String id = "";
                if (obj instanceof HashMap) {
                    Map rMap = (Map) obj;
                    resultFlag = String.valueOf(rMap.get("flag"));
                    id = String.valueOf(rMap.get("id"));
                } else if (obj instanceof ResultMsg) {
                    ResultMsg resultMsgB = (ResultMsg) obj;
                    resultFlag = resultMsgB.getFlag();
                } else {
                    ResultEntity resultEntity = (ResultEntity) obj;
                    resultFlag = Validator.isEmpty(resultEntity.getEntity()) ? "F" : "T";
                }
                Map<String, String> params = new HashMap<String, String>();
                params.put("id", id);
                log.info("本次业务处理结果resultFlag=" + resultFlag);
                if (StrUtil.isNotNull(flowCode) && "T".equals(resultFlag)) {
                    //业务执行成功
                    log.info("开始调用工作流flowCode=" + flowCode);
                    Method methodFlow = doInvoke(this.getClass(), request, response, methodType,
                            flowCode);
                    if (null != methodFlow) {
                        Object flowResult = methodFlow
                                .invoke(this, request, response, loginUser, params);
                        if (!ToolsUtil.isEmpty(flowResult)) {
                            log.info("流程处理完成！");
                        }
                    }
                }
                JSONObject array = JSONObject.fromObject(obj);
                this.outputJson(array.toString(), response, request.getParameter("callback"));
            }
        } else {
            gotoErrorPage(request, response, "请求方式有误或请求地址未定义");
        }
    }

    /**
     * 报名登记
     */
    @RequestMapping(value = "baoMing", method = "post")
    @Token(remove = true)
    protected ResultMsg baoMing(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "操作失败");
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity && !Validator.isEmpty(entity.getEntity())) {
            msg = new ResultMsg("T", "提交成功");
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * 会员信息保存
     */
    @RequestMapping(value = "memberSave", method = "post")
    @Token(remove = true)
    protected ResultMsg memberSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) memberPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("member").doInvoke(request, response, params);
        return msg;
    }

    /**
     * 会员信息删除
     */
    @RequestMapping(value = "memberDel", method = "post")
    @Token(remove = true)
    protected ResultMsg memberDel(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) memberPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("member").doInvoke(request, response, params);
        return msg;
    }

    /**
     * 会员信息保存
     */
    @RequestMapping(value = "orgSave", method = "post")
    @Token(remove = true)
    protected ResultMsg OrgSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) orgPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("org").doInvoke(request, response, params);
        return msg;
    }

    /**
     * 钱包，F002：开户提交
     */
    @RequestMapping(value = "F002", method = "post")
    protected Object F002(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, String> params = getParameterMap(request);
        ResultEntity entity = (ResultEntity) fusPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("fus")
        //.doInvoke(request, response, params);
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("flag", "F");
        resultMap.put("msg", "钱包检测通信失败");

        if ("true".equals(entity.getResult())) {
            if (null == entity.getEntity() || "false".equals(entity.getEntity().toString())) {
                resultMap.put("msg", entity.getMessage());
            } else {
                resultMap.put("flag", "T");//已经存在，直接使用
                resultMap.put("msg", entity.getMessage());
                request.getSession().setAttribute("fundsLogin", "T");//首次开通标记已经登录
                request.getSession().setAttribute("fundsUser", entity.getEntity());//开通标记钱包账户信息
            }
        }
        return resultMap;
    }

    /**
     * 钱包，F005：资金划转（充值/提现）
     */
    @RequestMapping(value = "F005", method = "post")
    protected Object F005(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, String> params = getParameterMap(request);
        ResultEntity entity = (ResultEntity) fusPlugin.doInvoke(request, response,
                params);// PortalPubFactory.getInstance().getPlugin("fus")
        //.doInvoke(request, response, params);
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("flag", "F");
        resultMap.put("msg", "操作失败");

        if ("true".equals(entity.getEntity().toString())) {
            resultMap.put("flag", "T");
            resultMap.put("msg", "操作成功");
        } else {
            if (entity.getMessage().indexOf("F005") > -1) {
                resultMap.put("msg", "可操作余额不足");
            }
        }
        return resultMap;
    }

    /**
     * 钱包，F008：登录
     */
    @RequestMapping(value = "F008", method = "post")
    protected Object F008(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, String> params = getParameterMap(request);
        ResultEntity entity = (ResultEntity) fusPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("fus")
        //.doInvoke(request, response, params);
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("flag", "F");
        resultMap.put("msg", "登录口令校验失败");

        if ("true".equals(entity.getResult())) {
            log.info("资金账号登录口令校验结果：" + entity.getMessage());
            if (!"false".equals(entity.getEntity().toString())
                    && entity.getMessage().indexOf("F000") > -1) {
                request.getSession().setAttribute("fundsLogin", "T");//标记已经登录
                request.getSession().setAttribute("fundsUser", entity.getEntity());//标记钱包账户信息
                resultMap.put("flag", "T");
                resultMap.put("msg", "钱包登录成功");
            }
        }
        return resultMap;
    }

    /**
     * 钱包，F010：为指定账号开户提交
     */
    @RequestMapping(value = "F010", method = "post")
    protected Object F010(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, String> params = getParameterMap(request);
        ResultEntity entity = (ResultEntity) fusPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("fus")
        //.doInvoke(request, response, params);
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("flag", "F");
        resultMap.put("msg", "钱包检测通信失败");

        if ("true".equals(entity.getResult())) {
            if (null == entity.getEntity() || "false".equals(entity.getEntity().toString())) {
                resultMap.put("msg", entity.getMessage());
            } else {
                resultMap.put("flag", "T");//已经存在，直接使用
                resultMap.put("msg", entity.getMessage());
            }
        }
        return resultMap;
    }

    /**
     * 会员信息删除
     */
    @RequestMapping(value = "orgDel", method = "post")
    //	@Token(remove = true)
    protected ResultMsg orgDel(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) orgPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("org").doInvoke(request, response, params);
        return msg;
    }

    /**
     * 项目信息保存
     */
    //	@Token(remove = true)
    @RequestMapping(value = "proSave", method = "post")
    protected Object proSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, Object> result = new HashMap<String, Object>();
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (Validator.isEmpty(entity.getEntity())) {
            result.put("flag", "F");
            result.put("msg", entity.getMessage());
        } else {
            Map map = (Map) entity.getEntity();
            String flag = StrUtil.doNull(String.valueOf(map.get("flag")), "F");
            result.put("flag", flag);
            result.put("msg", entity.getMessage());
            if ("T".equalsIgnoreCase(flag)) {
                result.put("proId", StrUtil.doNull(String.valueOf(map.get("proId")), ""));
                result.put("infoId", StrUtil.doNull(String.valueOf(map.get("infoId")), ""));
            }
        }

        return result;
    }

    /**
     * 项目信息修改
     */
    @Token(remove = true)
    @RequestMapping(value = "proEdit", method = "post")
    protected Object proEdit(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, Object> result = new HashMap<String, Object>();
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity() && "true".equals(String.valueOf(entity.getEntity()))) {
            result.put("flag", "T");
            result.put("msg", "操作成功");
        } else {
            result.put("flag", "F");
            result.put("msg", entity.getMessage());
        }
        return result;
    }

    /**
     * 流程启动
     */
    @Token(remove = true)
    @RequestMapping(value = "proStartFlow", method = "post")
    protected Object proStartFlow(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, Object> result = new HashMap<String, Object>();
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);// PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (Validator.isEmpty(entity.getEntity())) {
            result.put("flag", "F");
            result.put("msg", entity.getMessage());
        } else {

            Map map = (Map) entity.getEntity();
            String flag = StrUtil.doNull(String.valueOf(map.get("flag")), "F");
            if ("T".equals(flag)) {

                result.put("flag", flag);
                result.put("msg", entity.getMessage());
                result.put("proId", StrUtil.doNull(String.valueOf(map.get("proId")), ""));
                result.put("infoId", StrUtil.doNull(String.valueOf(map.get("infoId")), ""));
                map.put("id", StrUtil.doNull(String.valueOf(map.get("proId")), ""));
                initAudit(request, response, loginUser, params, map);
            } else {
                result.put("flag", "F");
                result.put("msg", entity.getMessage());
            }
        }
        return result;
    }

    //@Token(remove = true)
    @RequestMapping(value = "dictCateDel", method = "post")
    protected ResultMsg dictCateDel(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) dictPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("dict").doInvoke(request, response, params);

        if("T".equals(msg.getFlag())){
            Map<String, String> searchMap = new HashMap<>();
            searchMap.put("sysEname",StrUtil.doNull(params.get("sysEname"),"default"));
            createDictCateListDataFile(request,response,searchMap);
        }
        return msg;
    }

    //@Token(remove = true)
    @RequestMapping(value = "dictItemDel", method = "post")
    protected ResultMsg dictItemDel(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) dictPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("dict")
        //.doInvoke(request, response, params);
        if (!ToolsUtil.isEmpty(entity.getEntity())) {
            if ("true".equals(String.valueOf(entity.getEntity()))) {
                msg = new ResultMsg("T", "删除成功");
                //数据字典科目子项删除成功后，开始上传json静态文件
                createDictSelectDataFile(params);

            } else {
                msg = new ResultMsg("F", entity.getMessage());
            }
        }
        return msg;
    }

    @RequestMapping(value = "dictCateSave", method = "post")
    @Token(remove = true)
    protected ResultMsg dictCateSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) dictPlugin.doInvoke(request, response,params);
        if("T".equals(msg.getFlag())){
            Map<String, String> searchMap = new HashMap<>();
            searchMap.put("sysEname",StrUtil.doNull(params.get("sysEname"),"default"));
            createDictCateListDataFile(request,response,searchMap);
        }
        return msg;
    }

    @RequestMapping(value = "dictItemSave", method = "post")
    //@Token(remove = true)
    protected ResultMsg dictItemSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) dictPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("dict")
        //.doInvoke(request, response, params);
        if (!ToolsUtil.isEmpty(entity.getEntity())) {
            if ("true".equals(String.valueOf(entity.getEntity()))) {
                msg = new ResultMsg("T", "保存成功");

                //数据字典科目子项保存或者修改成功后，开始上传json静态文件
                createDictSelectDataFile(params);

            } else {
                msg = new ResultMsg("F", entity.getMessage());
            }
        }
        return msg;
    }

    /**
     * description:  项目挂牌
     */
    @RequestMapping(value = "regBrandPro", method = "post")
    @Token(remove = true)
    protected ResultMsg regBrandPro(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  项目摘牌
     */
    //	@Token(remove = true)
    @RequestMapping(value = "pickBrandPro", method = "post")
    protected ResultMsg pickBrandPro(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            String flag = String.valueOf(entity.getEntity());
            if ("H".equals(flag)) {
                msg = new ResultMsg("H", entity.getMessage());
            } else {
                msg = new ResultMsg("T", entity.getMessage());
            }
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  保存transUser信息
     */
    @RequestMapping(value = "userSave", method = "post")
    @Token(remove = true)
    protected ResultMsg userSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  修改transUser信息
     */
    @Token(remove = true)
    @RequestMapping(value = "userEdit", method = "post")
    protected ResultMsg userEdit(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  修改apply信息
     */
    @RequestMapping(value = "applyEdit", method = "post")
    //	@Token(remove = true)
    protected ResultMsg applyEdit(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  生成保证金划入单据
     */
    //	@Token(remove = true)
    @RequestMapping(value = "sendInvoice", method = "post")
    protected ResultMsg sendInvoice(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  生成退保单据
     */
    @Token(remove = true)
    @RequestMapping(value = "bailOut", method = "post")
    protected ResultMsg bailOut(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  生成价款划入单据
     */
    @Token(remove = true)
    @RequestMapping(value = "billIn", method = "post")
    protected ResultMsg billIn(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  生成价款划出单据
     */
    //	@Token(remove = true)
    @RequestMapping(value = "billOut", method = "post")
    protected ResultMsg billOut(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity() && "true"
                .equalsIgnoreCase(String.valueOf(entity.getEntity()))) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * 凭单支付交费--线上
     */
    @Token(remove = true)
    @RequestMapping(value = "billPay", method = "post")
    protected ResultMsg billPay(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "通信失败");
        Map<String, String> params = this.getParameterMap(request);
        if ("manager".equals(loginUser.getUserType())) {
            //业务人员通过项目ID查询凭单列表，无需传userEname。
            params.put("ifManager", "manager");
            ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                    params);//PortalPubFactory.getInstance().getPlugin("net")
            //.doInvoke(request, response, params);
            if (null != entity.getEntity()) {
                msg = new ResultMsg("T", "支付成功");
            } else {
                msg = new ResultMsg("F", entity.getMessage());
            }
            return msg;
        } else {
            //1.判断是否开通钱包；
            Map<String, String> fusMap = getParameterMap(request);
            fusMap.put("doCode", "F001");
            ResultEntity entity = (ResultEntity) fusPlugin.doInvoke(request, response,
                    fusMap);//PortalPubFactory.getInstance().getPlugin("fus")
            //.doInvoke(request, response, fusMap);
            if (!"true".equals(entity.getResult())) {
                return new ResultMsg("F00", "通信失败");
            }
            if (null == entity.getEntity()) {
                return new ResultMsg("F01", "您还未开通钱包，请先开通钱包！");
            }
            //2.判断账户口令是否正确
            String pass = String.valueOf(params.get("payPas"));
            if (StrUtil.isNull(pass)) {
                return new ResultMsg("F01", "资金账户口令不能为空！");
            }
            JSONObject fusJson = (JSONObject) entity.getEntity();
            try {
                if (!MD5Utils.crypt(MD5Utils.crypt(pass) + "iussoft")
                        .equals(fusJson.getString("passWord"))) {
                    return new ResultMsg("F02", "资金账户口令有误，请重新输入！");
                }
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            }
            //获取当前登录人资金账号
            String fundsAccount = fusJson.getString("userName");
            //3.判断钱包可用余额是否够；
            fusMap.put("doCode", "F004");
            entity = (ResultEntity) fusPlugin.doInvoke(request, response,
                    fusMap);//PortalPubFactory.getInstance().getPlugin("fus").doInvoke(request, response, fusMap);
            if (null != entity.getEntity() && "false".equals(entity.getEntity().toString())) {
                return new ResultMsg("F03", "余额查询失败，请联系管理员！");
            }
            Map<String, Object> funsBalMap = (Map<String, Object>) entity.getEntity();
            long m1 = Long.parseLong(funsBalMap.get("m1").toString());
            long billAmount = Math
                    .round(NumberUtils.getDouble(params.get("billAmount"), 0, true) * 100);
            if (m1 < billAmount) {
                return new ResultMsg("F04", "您当前有效资金不足，请及时充值！");
            }
            //4.调用凭单支付插件；
            params.put("payAcountNo", fundsAccount);
            entity = (ResultEntity) netPlugin.doInvoke(request, response,
                    params);//PortalPubFactory.getInstance().getPlugin("net").doInvoke(request, response, params);
            if (null != entity.getEntity()) {
                msg = new ResultMsg("T", "支付成功，请等待交易所确认！");
            } else {
                msg = new ResultMsg("F", entity.getMessage());
            }
            return msg;
        }
    }

    /**
     * 凭单支付交费--线下
     */
    @Token(remove = true)
    @RequestMapping(value = "billPayBelow", method = "post")
    protected ResultMsg billPayBelow(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "通信失败");
        Map<String, String> params = this.getParameterMap(request);
        if ("manager".equals(loginUser.getUserType())) {
            //业务人员通过项目ID查询凭单列表，无需传userEname。
            params.put("ifManager", "manager");
            ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                    params);//PortalPubFactory.getInstance().getPlugin("net")
            //.doInvoke(request, response, params);
            if (null != entity.getEntity()) {
                msg = new ResultMsg("T", "支付成功");
            } else {
                msg = new ResultMsg("F", entity.getMessage());
            }
            return msg;
        } else {
            //1.判断是否开通钱包；
            Map<String, String> fusMap = getParameterMap(request);
            fusMap.put("doCode", "F001");
            ResultEntity entity = (ResultEntity) fusPlugin.doInvoke(request, response,
                    fusMap);//PortalPubFactory.getInstance().getPlugin("fus")
            if (!"true".equals(entity.getResult())) {
                return new ResultMsg("F00", "通信失败");
            }
            if (null == entity.getEntity()) {
                return new ResultMsg("F01", "您还未开通钱包，请先开通钱包！");
            }
            //2.获取当前登录人资金账号
            JSONObject fusJson = (JSONObject) entity.getEntity();
            String fundsAccount = fusJson.getString("userName");
            //3.调用凭单支付插件；
            params.put("payAcountNo", fundsAccount);
            //params.put("payAcountNo", String.valueOf(params.get("sellBankNo")));
            entity = (ResultEntity) netPlugin.doInvoke(request, response,
                    params);//PortalPubFactory.getInstance().getPlugin("net").doInvoke(request, response, params);
            if (null != entity.getEntity()) {
                msg = new ResultMsg("T", "支付成功，请等待交易所确认！");
            } else {
                msg = new ResultMsg("F", entity.getMessage());
            }
            return msg;
        }
    }

    /**
     * description:  成交信息保存
     */
    @Token(remove = true)
    @RequestMapping(value = "dealSave", method = "post")
    protected Object dealSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("flag", "F");

        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            result.put("flag", "T");
            result.put("msg", entity.getMessage());
            result.put("id", String.valueOf(entity.getEntity()));
        } else {
            result.put("flag", "F");
            result.put("msg", entity.getMessage());
        }
        return result;
    }

    @RequestMapping(value = "auditSave", method = "post")
    @Token(remove = true)
    protected ResultEntity auditSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultEntity resultEntity = null;
        Map<String, String> params = this.getParameterMap(request);
        params.put("checkUser", loginUser.getUserEname());
        String doCode = params.get("doCode");
        if (!doCode.startsWith("audit")) {
            params.put("doCode", "auditSave");
        }
        resultEntity = (ResultEntity) auditPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("audit")
        //.doInvoke(request, response, params);
        return resultEntity;
    }

    /**
     * 1)流程往下一步走
     * 2）判断是否调用业务方法，并且调用
     */
    /**
    @RequestMapping(value = "flowNext", method = "post")
    @Token(remove = true)
    protected ResultMsg flowNext(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser, Map<String, String> dataMap) throws IOException {
        ResultMsg msg = new ResultMsg("F", "操作失败");
        log.info("【flow】flowNext is start...");
        Map<String, String> params = this.getParameterMap(request);
        log.info("【flow】flowMap params:" + params);
        String formId = params.get("pid");
        String result = params.get("auditFlag");
        String taskId = params.get("taskId");
        String processInsId = params.get("processInsId");
        String proId = params.get("proId");
        String lastUser = Validator.getDefaultStr(params.get("lastUser"), "");
        if (StrUtil.isNotNull(taskId)) {
            Map<String, String> flowMap = new HashMap<String, String>();
            flowMap.put("result", result);
            flowMap.put("taskId", taskId);
            flowMap.put("proId", proId);
            //			flowMap.put("lastUser", lastUser);
            Element rootElement = null;
            try {
                Document doc = FlowUtils.approve(flowMap);
                if (doc != null)
                    rootElement = doc.getRootElement();
            } catch (Exception e) {
                e.printStackTrace();
            }
            String resultText = rootElement.elementText("result");
            if ("T".equals(resultText)) {
                if (Validator.isNotNull(params.get("auditCode"))) {

                    if ("billIn".equals(request.getParameter("doCode"))) {
                        //由于billIn方法会自行启动新的工作流，且会init一个新的audit，所以不需要在此initAudit。
                    } else if ("100".equals(request.getParameter("proStatus"))) {
                        //当项目归档时，即状态为100时，不需要在此initAudit。
                    } else {
                        initAudit(request, response, loginUser, params, dataMap);
                    }
                }

                log.info("【flow】flowNext success！success！result:" + resultText);
            } else {
                String errMsg = rootElement.elementText("errmsg");
                log.error("【flow】flowNext error！error！result:" + errMsg);
            }
        } else {
            String taskType = params.get("taskType");
            //如果是state节点而不是task节点（默认是task节点）
            if (Validator.isNotNull(taskType) && "state".equals(taskType)) {
                String op = params.get("op");
                op = StrUtil.doNull(op, "4");
                try {
                    Document doc = FlowUtils.processInsOP(processInsId, op);
                    Element rootElement = null;
                    if (doc != null) {
                        rootElement = doc.getRootElement();
                    }
                    String resultText = rootElement.elementText("result");
                    if ("T".equals(resultText)) {
                        if (Validator.isNotNull(params.get("auditCode"))) {
                            initAudit(request, response, loginUser, params, dataMap);
                        }
                        log.info("【flow】flowNext success！success！result:" + resultText);
                    } else {
                        String errMsg = rootElement.elementText("errmsg");
                        log.error("【flow】flowNext error！error！result:" + errMsg);
                    }
                } catch (Exception e) {

                    e.printStackTrace();

                }
            } else {
                log.error("【flow】flowNext error！taskId is null");
            }
        }
        msg = new ResultMsg("T", "操作成功");
        return msg;
    }

    @RequestMapping(value = "dynamicallyTransition", method = "post")
    @Token(remove = true)
    protected ResultMsg dynamicallyTransition(HttpServletRequest request,
            HttpServletResponse response, LoginUser loginUser) throws Exception {
        ResultMsg msg = new ResultMsg("F", "失败");
        Map<String, String> mapFlow = new HashMap<String, String>();
        String processInsId = request.getParameter("processInsId");
        String sourceNode = request.getParameter("sourceNode");
        mapFlow.put("processInsId", processInsId);//流程实例名ID
        mapFlow.put("sourceNode", sourceNode);

        try {
            FlowUtils.processInsOP(processInsId, "4");
            Document doc = FlowUtils.dynamicallyTransition(processInsId, sourceNode);
            Element rootElement = null;
            if (doc != null) {
                rootElement = doc.getRootElement();
            }
            String resultText = rootElement.elementText("result");
            if ("T".equals(resultText)) {
                msg.setFlag("T");
                msg.setMsg(resultText);
                log.info("【flow】flowNext success！success！result:" + resultText);
            } else {
                String errMsg = rootElement.elementText("errmsg");
                log.error("【flow】flowNext error！error！result:" + errMsg);
            }
            String sysPass = "/flow?sysPass=" + ToolsUtil.getInstance().getValueByKey("sysEname");
            //            PubWebSorcketClient c = PortalUtil.getWebsocketFlowCLient(sysPass);
            //            if (!Validator.isEmpty(c)) {
            //                c.send(processInsId);
            //            }
        } catch (Exception e) {
            e.printStackTrace();

        }

        return msg;
    }
**/
    /**
     * description:
     *
     * @param request
     * @param response
     * @param loginUser
     * @param params 原生请求参数的map
     * @param map 内部处理后的map
     */
    private void initAudit(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser, Map<String, String> params, Map map) {
        Map<String, String> maps = new HashMap<String, String>();
        maps.put("pid",
                StrUtil.doNull(String.valueOf(params.get("pid")), String.valueOf(map.get("id"))));
        maps.put("proId",
                StrUtil.doNull(String.valueOf(params.get("proId")), String.valueOf(map.get("id"))));
        //只要进入到这个方法，目的就是初始化audit表，所以不需要接受doCode参数了，写死即可。
        maps.put("doCode",
                "auditSave");//auditSave既是新增方法也是修改方法，主要根据是否传主键auditsId来做判断。主键为auditsId，主要区分pro表、deal等表里的auditId，特此改名。

        String tableName = params.get("tableName");
        String colName = params.get("colName");

        if (Validator.isNotNull(tableName) && Validator.isNotNull(colName)) {
            maps.put("tableName", tableName);
            maps.put("colName", params.get("colName"));
            maps.put("taskName", params.get("taskName"));
            maps.put("checkUser", loginUser.getUserEname());
            maps.put("methodKey", "init");
            //流程实例ID的来源有两种：1、从页面中获取后传入后台2、内部处理后的map传入方法。
            maps.put("auditType", Validator
                    .getDefaultStr(params.get("auditType"), String.valueOf(map.get("auditId"))));
            maps.put("sysPass", ConfigUtil.getInstance().interfacePass());
            auditPlugin.doInvoke(request, response,
                    params);//PortalPubFactory.getInstance().getPlugin("audit").doInvoke(request, response, maps);
        }

    }

    ///以下稿件栏目相关////////////////////

    /**
     * description:  保存/修改栏目信息
     */
    @RequestMapping(value = "saveChannel", method = "post")
    @Token(remove = true)
    protected ResultMsg saveChannel(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        params.put("creatorId", loginUser.getUserEname());
        msg = (ResultMsg) wcmPlugin.doInvoke(request, response,
                params);// PortalPubFactory.getInstance().getPlugin("wcm").doInvoke(request, response, params);
        return msg;
    }

    /**
     * description:  保存/修改稿件信息
     */
    @RequestMapping(value = "saveArtice", method = "post")
    //@Token(remove = true)
    protected ResultMsg saveArtice(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        params.put("creatorId", loginUser.getUserEname());
        String sysName = request.getParameter("sysName");
        sysName = Validator.getDefaultStr(sysName, "cms");
        params.put("datasource", sysName);
        msg = (ResultMsg) wcmPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("wcm").doInvoke(request, response, params);
        return msg;
    }

    /**
     * description:  删除稿件信息
     */
    @RequestMapping(value = "delArtice", method = "post")
    //@Token(remove = true)
    protected ResultMsg delArtice(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        String sysName = request.getParameter("sysName");
        sysName = Validator.getDefaultStr(sysName, "cms");
        params.put("datasource", sysName);
        msg = (ResultMsg) wcmPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("wcm").doInvoke(request, response, params);
        return msg;
    }

    /**
     * description:  删除栏目信息
     */
    @RequestMapping(value = "dealChannel", method = "post")
    //@Token(remove = true)
    protected ResultMsg dealChannel(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        String sysName = request.getParameter("sysName");
        sysName = Validator.getDefaultStr(sysName, "cms");
        params.put("datasource", sysName);
        msg = (ResultMsg) wcmPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("wcm").doInvoke(request, response, params);
        return msg;
    }

    /**
     * description:  发布稿件
     */
    @RequestMapping(value = "publishArtice", method = "post")
    //@Token(remove = true)
    protected ResultMsg publishArtice(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        String sysName = request.getParameter("sysName");
        sysName = Validator.getDefaultStr(sysName, "cms");
        params.put("datasource", sysName);
        msg = (ResultMsg) wcmPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("wcm").doInvoke(request, response, params);
        return msg;
    }

    /**
     * description:  撤销稿件
     */
    @RequestMapping(value = "unpublishArtice", method = "post")
    //@Token(remove = true)
    protected ResultMsg unpublishArtice(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        String sysName = request.getParameter("sysName");
        sysName = Validator.getDefaultStr(sysName, "cms");
        params.put("datasource", sysName);
        msg = (ResultMsg) wcmPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("wcm").doInvoke(request, response, params);
        return msg;
    }

    @RequestMapping(value="pushArticeToChannel", method="post")
    protected ResultMsg pushArticeToChannel(HttpServletRequest request, HttpServletResponse response, LoginUser loginUser)
            throws IOException
    {
        ResultMsg msg = null;
        Map params = getParameterMap(request);
        request.getParameterValues("");
        this.log.info("pushArticeToChannel.params->" + params.toString());
        params.put("status", "0");
        String sysName = request.getParameter("sysName");
        sysName = Validator.getDefaultStr(sysName, "cms");
        params.put("datasource", sysName);
        msg = (ResultMsg)this.wcmPlugin.doInvoke(request, response, params);
        return msg;
    }

    /**
     * description:  预览稿件
     */
    @RequestMapping(value = "preViewAritce", method = "post")
    //@Token(remove = true)
    protected void preViewAritce(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException, ServletException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        String sysName = request.getParameter("sysName");
        sysName = Validator.getDefaultStr(sysName, "cms");
        params.put("datasource", sysName);
        msg = (ResultMsg) wcmPlugin.doInvoke(request, response,
                params);// PortalPubFactory.getInstance().getPlugin("wcm").doInvoke(request, response, params);
        if ("T".equals(msg.getFlag())) {
            request.setAttribute("infoStr", msg.getMsg());
            request.getRequestDispatcher("/WEB-INF/pages/wcm/viewAricte.jsp")
                    .forward(request, response);
        }
    }

    ///稿件栏目相关操作结束////////////////////

    /**
     * description:  生成交易凭证
     */
    @RequestMapping(value = "saveCred", method = "post")
    //	@Token(remove = true)
    protected ResultMsg saveCred(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "生成凭证失败");
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  删除交易凭证
     */
    @RequestMapping(value = "delCred", method = "post")
    @Token(remove = true)
    protected ResultMsg delCred(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net").doInvoke(request, response, params);
        return msg;
    }

    /**
     * description:  修改凭单状态
     */
    @RequestMapping(value = "editBillStatus", method = "post")
    //	@Token(remove = true)
    protected ResultMsg editBillStatus(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "正在处理");
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * description:  价款出纳
     */
    @RequestMapping(value = "billCashier", method = "post")
    @Token(remove = true)
    protected ResultMsg billCashier(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "正在处理");
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);// PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * 根据需求修改任何表的字段
     */
    @RequestMapping(value = "dymicSql", method = "post")
    //@Token(remove = true)
    protected Object dymicSql(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, String> params = getParameterMap(request);
        params.put("doCode", "dymicSql");
        //params.put("sqlKeyId", "ByDymicSql");
        params.put("resultType", "processSql");
        Map<String, Object> result = new HashMap<String, Object>();
        params.put("loginUser_userEname", loginUser.getUserEname());//确保其他表中没有该字段
        params = AdapterFactory.getInstance()
                .getReqParamForBefor("setReqParam,createInfo", params, request, response);//前拦截
        String execptionMsg = String.valueOf(params.get("execptionMsg"));
        if (StrUtil.isNotNull(execptionMsg)) {
            ResultMsg msg = new ResultMsg("F", execptionMsg);
            return msg;
        }
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        result.put("flag", String.valueOf(entity.getResult()));
        if (entity.getEntity() instanceof String) {
            if ("F".equals(String.valueOf(entity.getEntity())) || "T"
                    .equals(String.valueOf(entity.getEntity()))) {
                result.put("flag", entity.getEntity());
            }
        }
        result.put("msg", String.valueOf(entity.getMessage()));
        result.put("ids", entity.getEntity());
        return result;
    }

    /**
     * 根据需求修改任何表的字段----仅用来开发测试用
     */
    @RequestMapping(value = "testDymicSql", method = "get")
    protected Object testDymicSql(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        Map<String, String> params = getParameterMap(request);
        //params.put("sqlKeyId", "ByDymicSql");
        params.put("resultType", "processSql");
        Map<String, Object> result = new HashMap<String, Object>();
        params.put("loginUser_userEname", loginUser.getUserEname());//确保其他表中没有该字段
        params = AdapterFactory.getInstance()
                .getReqParamForBefor("setReqParam,createInfo", params, request, response);//前拦截
        String execptionMsg = String.valueOf(params.get("execptionMsg"));
        if (StrUtil.isNotNull(execptionMsg)) {
            ResultMsg msg = new ResultMsg("F", execptionMsg);
            return msg;
        }
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        result.put("flag", String.valueOf(entity.getResult()));
        result.put("msg", String.valueOf(entity.getMessage()));
        result.put("ids", entity.getEntity());
        return result;
    }

    /**
     * description:  价款出纳
     */
    @RequestMapping(value = "editBillInOut", method = "post")
    //	@Token(remove = true)
    protected ResultMsg editBillInOut(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "正在处理");
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) netPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("net")
        //.doInvoke(request, response, params);
        if (null != entity.getEntity()) {
            msg = new ResultMsg("T", entity.getMessage());
        } else {
            msg = new ResultMsg("F", entity.getMessage());
        }
        return msg;
    }

    /**
     * 部门保存
     */
    @RequestMapping(value = "deptSave", method = "post")
    //	@Token(remove = true)
    protected ResultMsg deptSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) orgPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("org").doInvoke(request, response, params);
        return msg;
    }

    /**
     * 部门删除
     */
    @RequestMapping(value = "deptDel", method = "post")
    //	@Token(remove = true)
    protected ResultMsg deptDel(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) orgPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("org").doInvoke(request, response, params);
        return msg;
    }

    /**
     * 部门保存
     */
    @RequestMapping(value = "roleSave", method = "post")
    //	@Token(remove = true)
    protected ResultMsg roleSave(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        msg = (ResultMsg) orgPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("org").doInvoke(request, response, params);
        return msg;
    }

    /**
     * 部门保存
     */
    @RequestMapping(value = "roleDel", method = "post")
    //	@Token(remove = true)
    protected ResultMsg roleDel(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("T", "删除操作失败");
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) orgPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("org")
        //.doInvoke(request, response, params);
        if ("T".equals(StrUtil.doNull(String.valueOf(entity.getEntity()), "F"))) {
            msg = new ResultMsg("T", "删除操作成功");
        }
        return msg;
    }

    @RequestMapping(value = "saveAct", method = "post")
    @Token(remove = true)
    protected ResultMsg saveAct(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        params.put("doCode", "saveAct");
        msg = (ResultMsg) uctPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("uct").doInvoke(request, response, params);
        return msg;
    }

    /**
     * 部门保存
     */
    @RequestMapping(value = "delAct", method = "post")
    //	@Token(remove = true)
    protected ResultMsg delAct(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("T", "删除操作失败");
        Map<String, String> params = this.getParameterMap(request);
        params.put("doCode", "delAct");
        msg = (ResultMsg) uctPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("uct").doInvoke(request, response, params);
        return msg;
    }


    /**
     * sys保存
     */
    @RequestMapping(value = "saveSys", method = "post")
    //	@Token(remove = true)
    protected ResultMsg saveSys(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        params.put("doCode", "saveSys");
        ResultEntity entity = (ResultEntity) orgPlugin.doInvoke(request, response,
                params);//PortalPubFactory.getInstance().getPlugin("org")
        //.doInvoke(request, response, params);
        if (Validator.isEmpty(entity.getEntity())) {
            msg = new ResultMsg("F", entity.getMessage());
        } else {
            msg = new ResultMsg("T", String.valueOf(entity.getEntity()));
        }
        return msg;
    }

    //////////////////以下对日志的处理doCode:logExecute////////////////////
    @RequestMapping(value = "logExecute", method = "post")
    //	@Token(remove = true)
    protected ResultMsg logExecute(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        //exeType=saveModel/delModel/saveModelDetail/delModelDetail
        ResultMsg msg = null;
        Map<String, String> params = this.getParameterMap(request);
        ResultEntity entity = (ResultEntity) uctPlugin.doInvoke(request, response, params);
        if (Validator.isEmpty(entity.getEntity())) {
            msg = new ResultMsg("F", entity.getMessage());
        } else {
            msg = new ResultMsg("T", String.valueOf(entity.getEntity()));
        }
        return msg;
    }

    /**
     * description:  excel导入 （${ctx}/trans/submit/impexcel?modelName=）
     * modelName 导入模板模型名称（必要）
     */
    @RequestMapping(value = "impexcel", method = "post")
    protected ResultMsg impExecl(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "操作失败");
        Map<String, String> params = new HashMap<String, String>();
        String pageName = request.getParameter("pageName");
        String formName = request.getParameter("formName");
        String sysName = StrUtil.doNull(request.getParameter("sysName"),"");
        //获取excel路径name值  filePathName---->excelFile
        String filePathName = ToolsUtil.getInstance().getLocalByKey("config.properties", "excel_file_path_name");
        //获取excel上传的本地文件路径  excelFile---->   E/:\\upload\\atta\\20180711\\1531289129010.xls
        String excelFile = request.getParameter(filePathName);
        params.put("pageName", pageName);
        params.put("formName", formName);
        params.put("excelFile", excelFile);
        if (StrUtil.isNull(excelFile) ) {
            msg = new ResultMsg("T", "未检测到相应的参数设置，代码号：【excelFile=" + excelFile + "】");
            return msg;
        }
        if (StrUtil.isNull(formName) || StrUtil.isNull(pageName)) {
            msg = new ResultMsg("T", "未检测到相应的参数设置，代码号：【" + pageName + ":" + formName + "】");
            return msg;
        }
        if (null == CacheHelper.getInstance().getIusParamCache(formName + "_" + pageName)) {
            msg = new ResultMsg("T", "未检测到相应的参数设置，代码号：【" + pageName + ":" + formName + "】");
            return msg;
        }
        try {
            long startTime = System.currentTimeMillis();
            String modelName = request.getParameter("modelName");//不可空
            String DOWNLOAD_URL = ToolsUtil.getInstance().getLocalByKey("config.properties", "DOWNLOAD_URL");
            String UPLOAD_DIRECTORY = ToolsUtil.getInstance().getLocalByKey("config.properties", "UPLOAD_DIRECTORY");
            String filePath = excelFile.replace(DOWNLOAD_URL,UPLOAD_DIRECTORY);
            long startTime2 = System.currentTimeMillis();
            ImportVo vo = new ImportVo();
            vo.setFilePath(filePath);
            vo.setModelName(modelName);//必要参数
            params.put("modelName",modelName);
            Map map = getDictMap(params);
            if(map == null){
                sendSocketMessage("数据字典文件读取出错！",sysName);
                msg =  new ResultMsg("F", "数据字典文件读取出错！");
                return msg;
            }else{
                vo.setParams("valueMap",map);
            }
            //正在解析Excel，请稍后。。。
            sendSocketMessage("正在解析Excel，请稍后。。。",sysName);
            ImportExecl impExcel = LoadManager.getInstance().getImp();
            List list = (List) impExcel.importData(vo);
            sendSocketMessage("Excel解析完成",sysName);
            if(list==null || list.size() == 0) {
                sendSocketMessage("文件解析出错", sysName);
                msg = new ResultMsg("F", "文件解析出错");
                return msg;
            }
            int result = 0;
            Map<String,Object> recordMap = new HashMap<>();
            Future<Integer> future1 = null;
            //正在进行Excel导入，请稍后。。。
            sendSocketMessage("正在进行Excel导入，请稍后。。。",sysName);
            //当模板名称为caProduction时，使用ProExcelImpTask线程任务
            if("caProduction".equals(modelName)){
                recordMap.put("totalCount",list.size());
                params.put("categoryPageName",request.getParameter("categoryPageName"));
                params.put("categoryFormName",request.getParameter("categoryFormName"));
                params.put("categoryModelTypes",request.getParameter("categoryModelTypes"));
                ProExcelImpTask task1 = null;
                //根据分类名称获取分类编号和分类id
                task1 = new ProExcelImpTask(params, list,recordMap ,loginUser);
                future1 = ScheduledExecutor.newInstance().getService().submit(task1);
            }else{
                ExcelImpTask task1 = null;
                task1 = new ExcelImpTask(params, list, loginUser);
                future1 = ScheduledExecutor.newInstance().getService().submit(task1);
            }
            result = future1.get();
            //Excel导入完成
            JSONArray jsonArray = new JSONArray();
            jsonArray.add(recordMap);
            sendSocketMessage("Excel导入完成",sysName);
            System.out.println("num=：" + result);
            long stopTime = System.currentTimeMillis();
            long dddd = stopTime - startTime;
            System.out.println("加上传时间：" + dddd);
            System.out.println("不加上传时间：" + (stopTime - startTime2) + "result=" + result);
            msg = new ResultMsg("T", jsonArray.toString());
        } catch (Exception ex) {
            ex.printStackTrace();
            return new ResultMsg("F", "文件解析出错");
        }
        return msg;
    }

    private void sendSocketMessage(String s,String sysName) {
        String sysPass = "?sysPass="+ConfigUtil.getInstance().getValueByKey("websocket_code_pass");
        String uri = ConfigUtil.getInstance().getValueByKey("public_websocket_url");
        String type = sysName;
        WebsocketClient.getInstance().sendMessageJson(uri,type,sysPass,s);
        //WebsocketClient.getInstance().sendMessage("","ws://39.104.104.181:11006/websocket/casc","?sysPass=e0cea4bb45e36c115356e46910c354af","{\"type\":\"casc\",\"message\":\"12323232\"}");
    }

    /**
     * 获取导入时相关数据字典的map
     * @param params
     * @return
     */
    private Map getDictMap(Map params) {
        Map map =null;
        try {
            map = new HashMap();
            params.put("methodName", "getModel");
            RuturnConfig config =(RuturnConfig)new ImplExeclPluginsImpl().execute(params);
            Map<String, RuturnPropertyParam> list = config.getPropertyMap();
            JSONArray json = null;
            FileInputStream fis = null;
            InputStreamReader isr = null;
            BufferedReader bufferedReader = null;
            for(String key:list.keySet()){
                RuturnPropertyParam ruturnPropertyParam = list.get(key);
                if(!("".equals(ruturnPropertyParam.getCodeTableName())) && ruturnPropertyParam.getCodeTableName()!=null){
                    //BufferedReader是可以按行读取文件
                    String filePath = ToolsUtil.getClassLoaderPath().replaceAll("WEB-INF/classes/", "")
                            + "js/dictData/dict-data-" + ruturnPropertyParam.getCodeTableName()+".js";
                    try {
                        fis = new FileInputStream(filePath);
                        isr = new InputStreamReader(fis, "UTF-8");
                        bufferedReader = new BufferedReader(isr);
                        String str = bufferedReader.readLine();
                        if(str != null){
                            json = JSONArray.fromObject(str);
                            for (int i = 1; i <json.size() ; i++) {
                                JSONObject obj = json.getJSONObject(i);
                                map.put(ruturnPropertyParam.getCodeTableName()+obj.get("text"),obj.get("id"));
                            }
                            System.out.println("str="+str);
                        }
                    }catch (IOException e){
                        e.printStackTrace();
                        return null;
                    }finally {
                        if (fis!=null){
                            fis.close();
                        }
                        if (isr!=null){
                            isr.close();
                        }
                        if (bufferedReader!=null){
                            bufferedReader.close();
                        }
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return map;
    }


    /**
     * description: 导出excel （${ctx}/trans/submit/outexcel?templateName=）
     * templateName 模板名称（必要）
     */
    @RequestMapping(value = "outexcel", method = "post")
    protected ResultMsg outexcel(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "操作失败");
        Map<String, String> params = this.getParameterMap(request);
        ExportVo vo = new ExportVo();
        String filePath = ToolsUtil.getClassLoaderPath()
                .replace("/WEB-INF/classes/", "/loadFile-out/");
        vo.setFilePath(filePath);
        String fileName = params.get("newFileName");
//        String orderBy = params.get("orderBy");
//        if(!"".equals(orderBy)){
//            params.put("orderBy","sm_component.create_time desc");
//        }
        vo.setNewFileName(fileName);
        vo.setTemplateName(params.get("templateName"));
        params.remove("templateName");
        params.remove("filePath");
        params.remove("newFileName");
        ExceloutTask task1 = new ExceloutTask(params.get("objName"), params, loginUser, vo);
        Future<Integer> future1 = ScheduledExecutor.newInstance().getService().submit(task1);
        try {
            if (future1.get() > 0) {
                String path_ = request.getContextPath();
                String basePath_ =
                        request.getScheme() + "://" + request.getServerName() + ":" + request
                                .getServerPort() + path_ + "/loadFile-out/" + fileName;
                msg = new ResultMsg("T", basePath_);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return new ResultMsg("F", "导出出错");
        }
        return msg;
    }

    /**
     * description: 导出excel （${ctx}/trans/submit/outtemplates）
     * templateName 模板名称（必要）
     */
    @RequestMapping(value = "outtemplates", method = "post")
    protected ResultMsg outtemplates(HttpServletRequest request, HttpServletResponse response,
                                 LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "操作失败");
        Map<String, String> params = this.getParameterMap(request);
        String filePath = ToolsUtil.getClassLoaderPath() + "templates/";
        //String filePath = ToolsUtil.getClassLoaderPath()
        //                .replace("/webapp/WEB-INF/classes/", "/templates/");
        String pageName = params.get("pageName");
        String formName = params.get("formName");
        String tempEname = params.get("smExpTemplates.tempEname");
        if(!tempEname.endsWith(".xls")){
            tempEname = tempEname+".xls";
            params.put("smExpTemplates.tempEname",tempEname);
        }
        if (StrUtil.isNull(formName) || StrUtil.isNull(pageName)) {
            msg = new ResultMsg("T", "未检测到相应的参数设置，代码号：【" + pageName + ":" + formName + "】");
            return msg;
        }
        if (null == CacheHelper.getInstance().getIusParamCache(formName + "_" + pageName)) {
            msg = new ResultMsg("T", "未检测到相应的参数设置，代码号：【" + pageName + ":" + formName + "】");
            return msg;
        }
//        String orderBy = params.get("orderBy");
//        if(!"".equals(orderBy)){
//            params.put("orderBy","sm_component.create_time desc");
//        }
        params.remove("templateName");
        params.remove("filePath");
        params.remove("newFileName");
        TemplatesOutTask task1 = new TemplatesOutTask(filePath, params, loginUser);
        Future<Integer> future1 = ScheduledExecutor.newInstance().getService().submit(task1);
        try {
            if (future1.get() > 0) {
                String path_ = request.getContextPath();
                String basePath_ =
                        request.getScheme() + "://" + request.getServerName() + ":" + request
                                .getServerPort() + path_ + "/loadTempFile-out/" + tempEname;
                msg = new ResultMsg("T", basePath_);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return new ResultMsg("F", "导出出错");
        }
        return msg;
    }
    /**
     * 工作日
     */
    @RequestMapping(value = "workday", method = "post")
    protected ResultMsg workday(HttpServletRequest request, HttpServletResponse response,
            LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "操作失败");
        Map<String, String> params = this.getParameterMap(request);

        String act = params.get("act");
        String day = params.get("day");
        String year = params.get("year");
        if ("set".equals(act)) {
            //设置是否工作日
            log.info("设置是否工作日：" + day);
            String isWorkday = params.get("isWorkday");
            WorkdayUtils.getInstance().setDay(day, "T".equals(isWorkday));
            msg = new ResultMsg("T", day + "设置为[" + isWorkday + "]完成");
        } else if ("after".equals(act)) {
            String ndays = request.getParameter("ndays");
            //Date startDay = com.apahce.tools.DateUtils.strToDate(day,"yyyyMMdd");
            //java.util.Date endDay  = WorkdayUtils.afterWorkday(startDay,NumberUtils.getInt(ndays,0));
            String endDay = null;
            try {
                endDay = WorkdayUtils.getInstance().afterWorkday(day, NumberUtils.getInt(ndays, 0));
                msg = new ResultMsg("T", endDay.trim());
            } catch (Exception e) {
                msg = new ResultMsg("T", "获取失败：" + e.getMessage());
                e.printStackTrace();
            }
        } else {
            log.info("查询" + year + "年的工作日数据");
            year = StrUtil.doNull(year, DateUtils.Now.fmt_yyyy());//默认取当前年
            java.util.List<Workday> list = WorkdayUtils.getInstance().getDayListOfYear(year);
            String jsonStr = JSONArray.fromObject(list).toString();
            msg = new ResultMsg("T", jsonStr);
        }
        log.info(JSONObject.fromObject(msg).toString());
        return msg;
    }

    /**
     * 加载【数据字典 科目列表 js文件】
     */
    private void createDictCateListDataFile(HttpServletRequest request,HttpServletResponse response,Map<String, String> params) {
        String sysEname = params.get("sysEname");
        params.put("datasource", "default");
        params.put("doCode","dictCateList");
        String sysPass = ConfigUtil.getInstance().interfacePass();
        params.put("sysPass",sysPass);
        log.info("系统【"+sysEname+"】数据字典列表查询->"+params);
        ResultEntity entity = (ResultEntity) dictPlugin.doInvoke(request, response,params);
        Map<String, Object> data = new HashMap<String, Object>();
        if (null == entity.getEntity()) {
            log.info("dictCateList 获取失败：" + entity.getMessage());
        } else {
            List list = (List) entity.getEntity();
            data.put("total", list.size());
            JSONArray jsonArray = new JSONArray();
            if(list.size()>0){
                for (Object obj:list){
                    DataCate dataCate = (DataCate)obj;
                    Map<String,String> item = new HashMap<>();
                    item.put("cateId",dataCate.getCateId());
                    item.put("cateEname",dataCate.getCateEname());
                    item.put("cateCname",dataCate.getCateCname());
                    item.put("cateRemark",StrUtil.doNull(dataCate.getCateRemark(),""));
                    item.put("viewType",StrUtil.doNull(dataCate.getViewType(),""));
                    jsonArray.add(item);
                }
            }
            data.put("rows",jsonArray);
            String fileName = "dict-cate-list-" + sysEname + ".js";
            log.info("系统【"+sysEname+"】数据字典列表生成js文件 start ->"+fileName);
            String filePath = ToolsUtil.getClassLoaderPath().replaceAll("WEB-INF/classes/", "")+ "common/"+sysEname+"/" + fileName;
            String enstr = JSONObject.fromObject(data).toString();
            log.info("系统【"+sysEname+"】数据字典列表数据 ->"+enstr);
            boolean fileResult = FileOperate.getInstance().newCreateFile(filePath, enstr);
            log.info("系统【"+sysEname+"】数据字典列表生成js文件 end ->"+fileResult);
        }
    }

    /**
     * 加载【数据字典 指定科目项目下条目数据js文件】
     */
    private void createDictSelectDataFile(Map<String, String> params) {
        System.out.println(params);
        String viewType = StrUtil.doNull(String.valueOf(params.get("viewType")),"");
        String doCode = "";
        Map<String, String> dictFileMap = new HashMap<String, String>();
        String cateEname = params.get("cateEname");
        if (!StrUtil.isNull(cateEname)) {
            if("2".equals(viewType)){
                doCode = "getTreeList";//获取
            }else {
                doCode = "getList";
            }
            String fileName = "dict-data-" + cateEname.toLowerCase() + ".js";
            Map<String, Object> dataMap2 = new HashMap<String, Object>();
            dataMap2.put("cateEname", cateEname);
            dataMap2.put("fatherValue", "0");
            dataMap2.put("doCode", doCode);
            ResultEntity entity2 = DictCoreClient.getInstance().dictSelect(dataMap2);

            Map<String, Object> data = new HashMap<String, Object>();
            String enstr = "";
            if (null == entity2 || !"true".equals(entity2.getResult())) {
                JSONObject array = JSONObject.fromObject("{}");
                log.info("数据字典[" + cateEname + "]数据查询异常=" + entity2.getMessage());
            } else {
                if("getTreeList".equals(doCode)){
                    JSONArray jsonArray = listToTreeDataJson((List<Map>)JSONArray.fromObject(entity2.getEntity()),"0");
                    enstr = String.valueOf(jsonArray.toString());
                }else{
                    enstr = String.valueOf(entity2.getEntity());
                }
                log.info("数据字典[" + cateEname + "]查询结果：" + enstr);
                log.info("开始生成json文件：" + fileName);
                String filePath = ToolsUtil.getClassLoaderPath().replaceAll("WEB-INF/classes/", "")
                        + "js/dictData/" + fileName;

                boolean fileResult = FileOperate.getInstance().newCreateFile(filePath, enstr);
                log.info("数据字典[" + cateEname + "]json文件生成结果：" + fileResult);
            }
        } else {
            log.info("请求的cateEname参数为空，不能生成json文件");
        }

    }
    /**
     * 纯树形结构的
     */
    private JSONArray listToTreeDataJson(List<Map> listData,String pid){
        JSONArray jsonArray = new JSONArray();
        //list生成JSON格式的树
        for(Map dms:listData){
            String fatherId = String.valueOf(dms.get("fatherId"));
            String treeLevel = String.valueOf(dms.get("treeLevel"));
            String itemValue = String.valueOf(dms.get("itemValue"));
            String itemId = String.valueOf(dms.get("itemId"));
            String itemText = String.valueOf(dms.get("itemText"));
//            String nodeIcon = StrUtil.doNull(String.valueOf(objMap.get("nodeIcon")),"");
            if(fatherId.equals(pid)){
                JSONObject jsonObj = new JSONObject();
                jsonObj.put("fatherId",fatherId);
                jsonObj.put("treeLevel",treeLevel);
                jsonObj.put("itemId",itemId);
                jsonObj.put("itemText",itemText);
                jsonObj.put("itemValue",itemValue);
//                jsonObj.put("nodeIcon",nodeIcon);
//                jsonObj.put("nodeName",nodeName);
                JSONArray array = listToTreeDataJson(listData,itemId);
                if(array.size()>0){
                    jsonObj.put("items",array);
                }
                jsonArray.add(jsonObj);
            }
        }
        return jsonArray;
    }
    /**
     * description: 导出word （${ctx}/trans/submit/outword?templateName=）
     * templateName 模板名称（必要）
     */
    @RequestMapping(value = "outword", method = "post")
    protected ResultMsg outword(HttpServletRequest request, HttpServletResponse response,
                                 LoginUser loginUser) throws IOException {
        ResultMsg msg = new ResultMsg("F", "操作失败");
        Map<String, String> params = this.getParameterMap(request);
        ExportVo vo = new ExportVo();
        String filePath = ToolsUtil.getClassLoaderPath()
                .replace("/WEB-INF/classes/", "/loadFile-out/");
        vo.setFilePath(filePath);
        String fileName = "tempceshi.doc";
        vo.setNewFileName(fileName);
        vo.setTemplateName("outfile.ftl");
        WordoutTask task1 = new WordoutTask(vo);
        Future<Integer> future1 = ScheduledExecutor.newInstance().getService().submit(task1);
        try {
            if (future1.get() > 0) {
                String path_ = request.getContextPath();
                String basePath_ =
                        request.getScheme() + "://" + request.getServerName() + ":" + request
                                .getServerPort() + path_ + "/loadFile-out/" + fileName;
                msg = new ResultMsg("T", basePath_);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return new ResultMsg("F", "导出出错");
        }
        return msg;
    }

    public static void main(String[] args)
    {
//        String sysPass = "?sysPass=e0cea4bb45e36c115356e46910c354af";
//        String uri = "ws://39.104.104.181:11006/websocket/";
//        String type = "casc";
//        WebsocketClient.getInstance().sendMessageJson(uri,type,sysPass,"1111111111111111");
//        //WebsocketClient.getInstance().sendMessage("","ws://39.104.104.181:11006/websocket/casc","?sysPass=e0cea4bb45e36c115356e46910c354af","{\"type\":\"casc\",\"message\":\"12323232\"}");
        List<DataMap> list = new ArrayList<>();
        DataMap dataMap1 =new DataMap();
        dataMap1.put("111","aaa");
        dataMap1.put("222","sss");
        dataMap1.put("333","ddd");
        dataMap1.put("444","fff");
        DataMap dataMap2 =new DataMap();
        dataMap2.put("111","aaa");
        dataMap2.put("222","sss");
        dataMap2.put("333","ddd");
        dataMap2.put("444","fff");
        list.add(dataMap1);
        list.add(dataMap2);
        JSONArray jsonArray = JSONArray.fromObject(list);
        System.out.println(jsonArray.toString());
    }



}
